/**
 * Created by DukeCrushIt on 2015/7/27.
 */
class MainScene extends eui.Component {
    private frameItem:FrameItem;
    public constructor(){
        super();
        this.name = "mainscene";
        this.skinName = "skins.scene.MainSceneSkin";
        this.frameItem = new FrameItem();
        this.frameItem.callObj = this;
        this.frameItem.callFun = this.update;
        this.addEventListener(egret.Event.ADDED_TO_STAGE,this.addedToStage, this );
        this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.removedFromStage, this);
    }

    public onBigData(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        SceneMgr.getInstance().switchScene(SceneMgr.SCENE_DATA);
    }

    public onPrize(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        SceneMgr.getInstance().switchScene(SceneMgr.SCENE_ACTIVITY);
        RedPointMgr.getInstance().update(RedPointMgr.ACHIEVE,false);
    }

    public onRecharge(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        if( this.rechargeModel == 0){
            FirstRechargePanel.getInstance().show();
        }else{
            TotalRechargePanel.getInstance().show();
        }
    }

    public onVip(evt:egret.Event){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        if(RES.isGroupLoaded("vippanel")){
            if( evt instanceof RES.ResourceEvent)
                RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onVip, this);
            VipPanel.getInstance().show();
        }else{
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onVip, this);
            RES.loadGroup("vippanel");
        }
    }
    private curShowLv = -1;
    public updateVipLevel(){
        if( this.curShowLv == Model.me.vipLevel) return;
        this.group_vip_level.text = Model.me.vipLevel+"";
        this.curShowLv = Model.me.vipLevel
    }
    private rechargeModel:number=0;
    public updateRechargeRelated(){
        this.updateVipLevel();
        var rechangeConfig:RechargeActivityConfig = ActivityMgr.getInstance().getCurRechargeConfig();
        this.rechargeModel =  rechangeConfig.type == 1 ? 0 :1 ;
        this.img_charge.source = this.rechargeModel == 0 ? "fr_icon":"img_recharge_ico";
        RedPointMgr.getInstance().update(RedPointMgr.RECHARGE_ICON,ActivityMgr.getInstance().getRechargeAwardable());
    }

    public onChat(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        SceneMgr.getInstance().switchScene(SceneMgr.SCENE_CHAT);
        RedPointMgr.getInstance().update(RedPointMgr.CHAT_ICON,false);
    }

    public onSetup(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        SetupPanel.getInstance().show();
    }

    public onMail(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        SceneMgr.getInstance().switchScene(SceneMgr.SCENE_MAIL);
    }

    public onMoneyCat(evt:egret.Event){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        if(RES.isGroupLoaded("moneycat")){
            if( evt instanceof RES.ResourceEvent)
                RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onMoneyCat, this);
            MoneyCatPanel.getInstance().show();
        }else{
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onMoneyCat, this);
            RES.loadGroup("moneycat");
        }
    }

    public onGoldrenFinger(evt:egret.Event){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        if(RES.isGroupLoaded("gf")){
            if( evt instanceof RES.ResourceEvent)
                RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onGoldrenFinger, this);
            GoldenFingerPanel.getInstance().show();
        }else{
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onGoldrenFinger, this);
            RES.loadGroup("gf");
        }
    }

    private onCollections(evt:egret.TouchEvent){
        CollectionPanel.getInstance().show();
    }

    private onBbs(evt:egret.TouchEvent){
        window["forum"]();
    }

    private onShield(evt:egret.TouchEvent){
        ShieldCommentPanel.getInstance().show();
    }

    private onRichman(evt :egret.TouchEvent ){
        if( RES.isGroupLoaded("richman")){
            RichMan.getInstance().show();
            RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onRichman, this);

        } else {
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onRichman, this);
            RES.loadGroup("richman");
        }
    }

    private onBuyLimitHair(evt:egret.Event){
        if( RES.isGroupLoaded("limitbuy")){
            LimitBuyHair.getInstance().show();
            RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onBuyLimitHair, this);

        } else {
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onBuyLimitHair, this);
            RES.loadGroup("limitbuy");
        }
    }
    private onBuyLimitDec(evt:egret.Event){
        if( RES.isGroupLoaded("limitbuy")){
            LimitBuyDecorate.getInstance().show();
            RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onBuyLimitDec, this);
        } else {
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onBuyLimitDec, this);
            RES.loadGroup("limitbuy");
        }
    }
    public onInfoBack(data){
        ActivityMgr.getInstance().limitHairBuyInfo = data;
        this.checkBuyHairLimit();
    }

    public checkBuyHairLimit(){
        var config =  ActivityMgr.getInstance().getActivityConfigById(ActivityMgr.ACTIVITY_LIMIT_BUY_HAIR);
        var info = ActivityMgr.getInstance().limitHairBuyInfo;
        if( config &&  Model.finishedMissions && info){
            this.img_buy_hair.visible = !info.award && this.checkMissions(config) && info.expireTime > Model.SYSTIME;
        }
    }
    public checkMissions(config){
        var arr:number[];
        if( Model.me.myType == Model.GOOD_TYPE_CAT){
            arr = config.config[0].catMissionIds;
        }else{
            arr = config.config[0].dogMissionIds;
        }
        var len =  arr.length;
        for(var i=0; i< len; i++){
            if(Model.finishedMissions.indexOf(arr[i]) == -1){
                return false;
            }
        }
        return true;
    }
    private addedToStage(evt:egret.Event){
        if( !Model.myDecorates)
            window["__iornaments"]();
        this.img_big_data.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBigData,this);
        this.img_prize.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onPrize, this);
        this.img_charge.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRecharge,this);
        this.img_bag.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onBag, this);
        this.img_vip.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onVip, this);
        this.img_chat.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onChat, this);
        this.img_mail.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onMail, this);
        this.img_setup.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onSetup, this);
        this.img_money_cat.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onMoneyCat, this);
        this.img_gf.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onGoldrenFinger, this);
        this.img_collect.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onCollections, this);
        this.img_bbs.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onBbs, this);
        this.img_shield.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onShield, this);
        this.img_buy_hair.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onBuyLimitHair, this);
        this.img_bug_dec.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBuyLimitDec, this);
        this.img_richman.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRichman, this);
        this.updatePropList();
        this.updateNoWarBuff();
        this.updateShield();
        this.updateGuildLogo();
        if(ActivityMgr.getInstance().chargeInfo)
            this.updateRechargeRelated();
        if( !GravitySystem.getInstance().exceptionArea){
            var rect = new egret.Rectangle(this.img_bag.x-20,this.img_bag.y-30,90,100);
            GravitySystem.getInstance().exceptionArea = rect;
            PetMgr.getInstance().excludeArea = rect;
        }
        if(!ActivityMgr.getInstance().moneyCatInfo)
            window["__moneyCatInfo"]();

        if( !ActivityMgr.getInstance().vipInfo){
            window["__vipInfo"]();
        }
    }
    public checkRequestLimitHair(){
        if( this.checkLimitHairShow() && !ActivityMgr.getInstance().limitHairBuyInfo){
            window["__limitHairInfo"]();
        }
    }
    private checkLimitHairShow(){
        if( !Model.finishedMissions) return false;
        var config =  ActivityMgr.getInstance().getActivityConfigById(ActivityMgr.ACTIVITY_LIMIT_BUY_HAIR);
        if (!config) return;
        var arr:number[];
        if( Model.me.myType == Model.GOOD_TYPE_CAT){
            arr = config.config[0].catMissionIds;
        }else{
            arr = config.config[0].dogMissionIds;
        }
        var len =  arr.length;
        for(var i=0; i< len; i++){
            if(Model.finishedMissions.indexOf(arr[i]) == -1){
                this.img_buy_hair.visible = false;
                return false;
            }
        }
        return true;
    }

    public checkMoneyCatShow(){
        this.img_money_cat.visible = ActivityMgr.getInstance().getCurMoneyCatConfig() != null;
        if( !this.img_money_cat.visible && RES.isGroupLoaded("moneycat")){
            RES.destroyRes("moneycat");
        }
        var curConfig:MoneyCatAcitivityConfig = ActivityMgr.getInstance().getCurMoneyCatConfig();
        RedPointMgr.getInstance().update(RedPointMgr.MONEY_CAT_ICON,curConfig!=null && curConfig.diamond <=  ActivityMgr.getInstance().moneyCatInfo.totalCharge );
    }

    private removedFromStage(evt:egret.Event){
        this.img_big_data.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onBigData,this);
        this.img_prize.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onPrize, this);
        this.img_charge.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onRecharge,this);
        this.img_bag.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onBag, this);
        this.img_vip.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onVip, this);
        this.img_chat.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onChat, this);
        this.img_mail.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onMail, this);
        this.img_setup.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onSetup, this);
        this.img_money_cat.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onMoneyCat, this);
        this.img_gf.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onGoldrenFinger, this);
        this.img_collect.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onCollections, this);
        this.img_bbs.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onBbs, this);
        this.img_shield.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onShield, this);
        this.img_buy_hair.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onBuyLimitHair, this);
        this.img_bug_dec.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onBuyLimitDec, this);
        this.img_richman.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onRichman, this);
        FrameMgr.getInstance().delController(this.name);
    }

    public itemGroup:eui.Group;
    public group_vip_level:eui.BitmapLabel;
    public img_bag_bg:eui.Image;

    public img_big_data:eui.Image;
    public img_prize:eui.Image;
    public img_charge:eui.Image;
    public img_join_qq:eui.Image;
    public img_bag:eui.Image;
    public itemList:eui.List;

    public img_frame:eui.Image;
    public img_doll:eui.Image;
    public img_nest:eui.Image;
    public img_vip:eui.Image;
    public img_chat:eui.Image;
    public img_setup:eui.Image;
    public img_mail:eui.Image;
    public img_head:eui.Image;
    public img_money_cat:eui.Image;
    public img_gf:eui.Image;
    public img_collect:eui.Image;
    public img_bbs:eui.Image;
    public img_no_war:eui.Image;
    public time_no_war:eui.BitmapLabel;
    public img_shield:eui.Image;
    public img_guild_logo:eui.Image;
    public img_buy_hair:eui.Image;
    public img_richman:eui.Image;
    public img_bug_dec: eui.Image;

    public hint_money_cat: eui.Image;
    public hint_chat:eui.Image;
    public hint_mail:eui.Image;
    public hint_activity:eui.Image;
    public hint_recharge:eui.Image;
    public hint_vip_mission:eui.Image;
    public partAdded(name:string, instance:any){
        super.partAdded(name, instance);
        if(name == "img_big_data"){
            this.img_big_data = instance;
        } else if (name == "img_richman"){ 
            this.img_richman = instance;
        } else if (name == "img_bug_dec ") { 
            this.img_bug_dec = instance;
        }  else if(name == "img_prize") {
            this.img_prize = instance;
        }else if( name == "img_charge"){
            this.img_charge = instance;
        }else if( name == "img_join_qq"){
            this.img_join_qq = instance;
        }else if( name == "img_nest"){
            this.img_nest = instance;
        }else if( name == "img_doll"){
            this.img_doll = instance;
        }else if( name == "img_frame"){
            this.img_frame = instance;
        }else if( name == "img_bag"){
            this.img_bag = instance;
        }else if( name == "itemList" ){
            this.itemList = instance;
            this.propProvider = new eui.ArrayCollection();
            this.itemList.itemRenderer = PropItemRender;
            this.itemList.dataProvider = this.propProvider;
            this.itemList.layout = new eui.HorizontalLayout();
        }else if( name == "itemGroup" ){
            this.itemGroup = instance;
            this.itemGroup.x = 420;
        }else if( name == "img_bag_bg"){
            this.img_bag_bg = instance;
        }else if( name == "img_vip"){
            this.img_vip = instance;
        }else if( name == "img_chat"){
            this.img_chat = instance;
        }else if( name == "hint_mail"){
            this.hint_mail = instance;
            RedPointMgr.getInstance().registerPoint(RedPointMgr.MAIL_ICON,instance);
        }else if( name == "hint_chat"){
            this.hint_chat = instance;
            RedPointMgr.getInstance().registerPoint(RedPointMgr.CHAT_ICON,instance);
        }else if( name == "hint_money_cat"){
            this.hint_money_cat = instance;
            RedPointMgr.getInstance().registerPoint(RedPointMgr.MONEY_CAT_ICON,instance);
        }else if( name == "hint_activity"){
            this.hint_activity = instance;
            RedPointMgr.getInstance().registerPoint(RedPointMgr.ACTIVITY_ICON,instance);
        }else if( name == "img_setup"){
            this.img_setup = instance;
        }else if( name == "img_mail"){
            this.img_mail = instance;
        }else if( name == "group_vip_level"){
            this.group_vip_level = instance;
        }else if( name == "hint_recharge"){
            this.hint_recharge = instance;
            RedPointMgr.getInstance().registerPoint(RedPointMgr.RECHARGE_ICON,instance);
        }else if( name == "img_money_cat"){
            this.img_money_cat = instance;
        }else if( name == "img_gf"){
            this.img_gf = instance;
        }else if( name == "hint_vip_mission"){
            this.hint_vip_mission = instance;
            RedPointMgr.getInstance().registerPoint(RedPointMgr.VIP_MISSION,instance);
        }else if( name == "img_bbs"){
            this.img_bbs = instance;
            this.img_bbs.visible = Model.me.platform == PlatformEnum.QQBROWSER;
        }else if( name == "img_collect"){
            this.img_collect = instance;
            this.img_collect.visible = PlatformEnum.QQBROWSER == Model.me.platform;
        }else if( name == "img_head"){
            this.img_head = instance;
            //this.img_head.source = Model.me.figureurl;
            if( Model.me.platform != PlatformEnum.QQBROWSER){
                this.img_head.source = Model.me.figureurl;
            }else{
                this.img_head.source = RES.getRes("default_head_"+(Model.me.id%5));
            }
        }else if( name == "time_no_war"){
            this.time_no_war = instance;
            this.time_no_war.textAlign = "center";
        }else if( name == "img_no_war"){
            this.img_no_war = instance;
        }else if( name == "img_shield"){
            this.img_shield = instance;
        }else if( name == "img_guild_logo"){
            this.img_guild_logo = instance;
        }else if( name == "img_buy_hair"){
            this.img_buy_hair = instance;
        }
    }

    public updateGuildLogo(){
        // var logo = GuildMgr.getInstance().guildLogo;
        // if( logo ){
        //     this.img_guild_logo.visible = true;
        //     this.img_guild_logo.source =  GameConst.Res_Root+"resource/assets/medals/"+logo.logoId+".png";
        // }else{
        //     this.img_guild_logo.visible = false;
        // }
    }

    private update(){
        if( this.noWarBuff){
            var timeLeft:number = this.noWarBuff.endTime - Model.SYSTIME;
            if( timeLeft > 0){
                var str:string = GetTimeStr(timeLeft,2,true);
                this.time_no_war.text = str;
            }else{
                FrameMgr.getInstance().delController(this.name);
                this.img_no_war.visible = this.time_no_war.visible = false;
            }
        }else{
            FrameMgr.getInstance().delController(this.name);
            this.img_no_war.visible = this.time_no_war.visible = false;
        }
    }
    private shieldBuff:BuffInfo;
    public updateShield(){
        this.shieldBuff = BuffMgr.getInstance().getBuffById(BuffMgr.SHIELD_BUFF);
        this.img_shield.visible = this.shieldBuff && this.shieldBuff.endTime > Model.SYSTIME;
    }

    private noWarBuff:BuffInfo;
    public updateNoWarBuff(){
        this.noWarBuff = BuffMgr.getInstance().getBuffById(BuffMgr.NO_WAR_BUFF);
        if(this.noWarBuff){
            this.img_no_war.visible = this.time_no_war.visible = true;
            if( !FrameMgr.getInstance().isUnderControl(this.name))
                FrameMgr.getInstance().addControll(this.frameItem);
        }else{
            if( FrameMgr.getInstance().isUnderControl(this.name))
                FrameMgr.getInstance().delController(this.name);

            this.img_no_war.visible = this.time_no_war.visible = false;
        }
    }

    public updateItems(){
        if( !Model.currentDecorators ) return;
        var type = this.getOriginal(Model.DEC_BG);
        PetMgr.getInstance().changeBg(type);

        type = this.getOriginal(Model.DEC_NEST);
        this.img_nest.visible = type != 0;
        if( type != 0)
            this.img_nest.source = GameConst.Res_Root+"resource/assets/decorates/"+type+ ".png";

        type = this.getOriginal(Model.DEC_TOY);
        this.img_doll.visible = type != 0;
        if( type != 0)
            this.img_doll.source = GameConst.Res_Root+"resource/assets/decorates/"+type+ ".png";

        type = this.getOriginal(Model.DEC_FRAME);
        this.img_head.visible = this.img_frame.visible = type != 0;
        if( type != 0)
            this.img_frame.source = GameConst.Res_Root+"resource/assets/decorates/"+type+ ".png";

        type = this.getOriginal(Model.DEC_HAT);
        if( type != 0)
            RES.getResByUrl(GameConst.Res_Root+"resource/assets/decorates/"+type+ ".png",this.onHatComplete,this);
        else
            AnimationController.getInstance().setSlotDisplay("mypet","tou",false);

        type = this.getOriginal(Model.DEC_GLASS);
        if( type != 0)
            RES.getResByUrl(GameConst.Res_Root+"resource/assets/decorates/"+type+ ".png",this.onGlassComplete,this);
        else
            AnimationController.getInstance().setSlotDisplay("mypet","bozi",false);

        type = this.getOriginal(Model.DEC_NECKLACE);
        if( type != 0)
            RES.getResByUrl(GameConst.Res_Root+"resource/assets/decorates/"+type+ ".png",this.onNeckComplete,this);
        else
            AnimationController.getInstance().setSlotDisplay("mypet","yanjing",false);
    }

    private getOriginal(classify:number = 0){
        if( !Model.currentDecorators ) return 0;
        var petid = PetMgr.getInstance().curPet.petId;
        var arr = Model.currentDecorators
        if( !arr || arr.length == 0) return 0;
        var dec:DecorateInfo;
        var len = arr.length;
        for( var i = 0 ; i < len; i++){
            dec = arr[i];
            if( dec.classify == classify && dec.petId == petid){
                return dec.goodsId;
            }
        }
        return 0;
    }
    private onHatComplete(hehe){
        AnimationController.getInstance().setSlotDisplay("mypet","tou",true,hehe);
    }
    private onGlassComplete(hehe){
        AnimationController.getInstance().setSlotDisplay("mypet","yanjing",true,hehe);
    }
    private onNeckComplete(hehe){
        AnimationController.getInstance().setSlotDisplay("mypet","bozi",true,hehe);
    }

    private propProvider:eui.ArrayCollection;
    public updatePropList(){
        var arr = [];
        var len = Model.props.length;
        var goodInfo:GoodInfo;
        var propInfo:PropInfo;
        for( var idx = 0; idx < len; idx++){
            propInfo = Model.props[idx];
            goodInfo = Model.GetGoodInfoById(propInfo.propId);
            if( goodInfo.type == Model.GOOD_TYPE_ITEM && Model.props[idx].count != 0){
                arr.push(Model.props[idx]);
            }
        }
        this.propProvider.source =  arr;
        if(arr.length == 0 && this.itemGroup.x == 70){
            this.onBag(null);
        }
    }
    private onBag(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        if( Model.props.length == 0 || this.propProvider.source.length == 0){
            if( this.itemGroup.x != 420){
                if( Model.GuideType == "bag"  || Model.GuideType == "useprop") return;
                var tw:egret.Tween = egret.Tween.get(this.itemGroup,{onChange:this.updateMask,onChangeObj:this},null,true);
                this.isLeft = false;
                tw.to({x:420,},300);
            }else{
                ShowHint(GameConst.NO_PROPS);
            }
        }else{
            if( this.itemGroup.x == 420){
                tw = egret.Tween.get(this.itemGroup,{onChange:this.updateMask,onChangeObj:this},null,true);
                this.isLeft = true;
                tw.to({x:70,},300);
                Model.checkGuide("bag");
            }else{
                if( Model.GuideType == "bag" || Model.GuideType == "useprop") return;
                tw = egret.Tween.get(this.itemGroup,{onChange:this.updateMask,onChangeObj:this},null,true);
                this.isLeft = false;
                tw.to({x:420,},300);
            }
        }
    }
    private isLeft:boolean;
    private updateMask(){
        var showWidth:number;
        if( this.isLeft){
            showWidth = 420-(this.itemGroup.x-20);
        }else{
            showWidth = 420 - this.itemGroup.x;
        }
        this.maskForItemGroup.width = showWidth;
        this.itemGroup.mask = this.maskForItemGroup;
    }

    private maskForItemGroup:egret.Rectangle;
    public childrenCreated(){
        super.childrenCreated();
        this.maskForItemGroup = new egret.Rectangle(0,0,0,60);
        this.itemGroup.mask = this.maskForItemGroup;
    }

    private static _instance:MainScene;
    public static getInstance():MainScene{
        if( MainScene._instance == null)
            MainScene._instance = new MainScene();
        return MainScene._instance;
    }
}